package vn.sunnet.game.SinhTon.global;

import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Preferences;
import com.badlogic.gdx.utils.Array;

public class Setting {
	public static Preferences preferences = Gdx.app.getPreferences("nk");

	// String
	public static String MAP = "map";
	public static String STAGE = "Stage"; // chặng

	public static String COIN = "Coin";
	public static String GUN = "Gun";
	public static String LOCOT = "Locot";

	public static String MUSIC = "Music";
	public static String SOUND = "Sound";
	public static String VIBRATE = "Vibrate"; // co rung man hinh hay ko?

	// Mang chua id cac loai sung co the su dung trong game
	public static Array<Integer> arrGunsCanUse;

	public static void loadPreferences() {
		//if (!preferences.contains(COIN))
			Setting.setCoin(10000000);
		Setting.setGun(1);
		Setting.setLocot(1);
//		Setting.putBoolean("MAP" + Assets.map, true);
		for(int i=0;i<10;i++)
		Setting.putBoolean("MAP" + i, true);
//		Setting.putBoolean("MAP" + 2, true);
//		Setting.putBoolean("MAP" + 3, true);
//		Setting.putBoolean("MAP" + 4, true);
//		Setting.putBoolean("MAP" + 5, true);
//		Setting.putBoolean("MAP" + 6, true);
//		Setting.putBoolean("MAP" + 7, true);
//		Setting.putBoolean("MAP" + 8, true);
//		Setting.putBoolean("MAP" + 9, true);
//		Setting.putBoolean("MAP" + 10, true);
		
//		Setting.putBoolean("STAGE" + Assets.map + "" + Assets.stage, true);
		for(int i=0;i<10;i++)
		Setting.putBoolean("STAGE" + i + "" +i, true);
//		Setting.putBoolean("STAGE" + 1 + "" + 2, true);
//		Setting.putBoolean("STAGE" + 1 + "" + 3, true);
//		Setting.putBoolean("STAGE" + 1 + "" + 4, true);
//		Setting.putBoolean("STAGE" + 1 + "" + 5, true);
//		Setting.putBoolean("STAGE" + 1 + "" + 6, true);
//		
//		Setting.putBoolean("STAGE" + 2 + "" + 1, true);
//		Setting.putBoolean("STAGE" + 2 + "" + 2, true);
//		Setting.putBoolean("STAGE" + 2 + "" + 3, true);
//		Setting.putBoolean("STAGE" + 2 + "" + 4, true);
//		Setting.putBoolean("STAGE" + 2 + "" + 5, true);
//		Setting.putBoolean("STAGE" + 2 + "" + 6, true);
//		
//		Setting.putBoolean("STAGE" + 3 + "" + 1, true);
//		Setting.putBoolean("STAGE" + 3 + "" + 2, true);
//		Setting.putBoolean("STAGE" + 3 + "" + 3, true);
//		Setting.putBoolean("STAGE" + 3 + "" + 4, true);
//		Setting.putBoolean("STAGE" + 3 + "" + 5, true);
//		Setting.putBoolean("STAGE" + 3 + "" + 6, true);
//		
//		Setting.putBoolean("STAGE" + 4 + "" + 1, true);
//		Setting.putBoolean("STAGE" + 4 + "" + 2, true);
//		Setting.putBoolean("STAGE" + 4 + "" + 3, true);
//		Setting.putBoolean("STAGE" + 4 + "" + 4, true);
//		Setting.putBoolean("STAGE" + 4 + "" + 5, true);
//		Setting.putBoolean("STAGE" + 4 + "" + 6, true);
//		
//		Setting.putBoolean("STAGE" + 5 + "" + 1, true);
//		Setting.putBoolean("STAGE" + 5 + "" + 2, true);
//		Setting.putBoolean("STAGE" + 5 + "" + 3, true);
//		Setting.putBoolean("STAGE" + 5 + "" + 4, true);
//		Setting.putBoolean("STAGE" + 5 + "" + 5, true);
//		Setting.putBoolean("STAGE" + 5 + "" + 6, true);
//		
//		Setting.putBoolean("STAGE" + 6 + "" + 1, true);
//		Setting.putBoolean("STAGE" + 6 + "" + 2, true);
//		Setting.putBoolean("STAGE" + 6 + "" + 3, true);
//		Setting.putBoolean("STAGE" + 6 + "" + 4, true);
//		Setting.putBoolean("STAGE" + 6 + "" + 5, true);
//		Setting.putBoolean("STAGE" + 6 + "" + 6, true);
//		
//		Setting.putBoolean("STAGE" + 7 + "" + 1, true);
//		Setting.putBoolean("STAGE" + 7 + "" + 2, true);
//		Setting.putBoolean("STAGE" + 7 + "" + 3, true);
//		Setting.putBoolean("STAGE" + 7 + "" + 4, true);
//		Setting.putBoolean("STAGE" + 7 + "" + 5, true);
//		Setting.putBoolean("STAGE" + 7 + "" + 6, true);
//		
//		Setting.putBoolean("STAGE" + 8 + "" + 1, true);
//		Setting.putBoolean("STAGE" + 8 + "" + 2, true);
//		Setting.putBoolean("STAGE" + 8 + "" + 3, true);
//		Setting.putBoolean("STAGE" + 8 + "" + 4, true);
//		Setting.putBoolean("STAGE" + 8 + "" + 5, true);
//		Setting.putBoolean("STAGE" + 8 + "" + 6, true);
//		
//		Setting.putBoolean("STAGE" + 9 + "" + 1, true);
//		Setting.putBoolean("STAGE" + 9 + "" + 2, true);
//		Setting.putBoolean("STAGE" + 9 + "" + 3, true);
//		Setting.putBoolean("STAGE" + 9 + "" + 4, true);
//		Setting.putBoolean("STAGE" + 9 + "" + 5, true);
//		Setting.putBoolean("STAGE" + 9 + "" + 6, true);
//		
//		Setting.putBoolean("STAGE" + 10 + "" + 1, true);
//		Setting.putBoolean("STAGE" + 10 + "" + 2, true);
//		Setting.putBoolean("STAGE" + 10 + "" + 3, true);
//		Setting.putBoolean("STAGE" + 10 + "" + 4, true);
//		Setting.putBoolean("STAGE" + 10 + "" + 5, true);
		
		Setting.putBoolean(MUSIC, true);
		Setting.putBoolean(SOUND, true);
		Setting.putBoolean(VIBRATE, true);

		arrGunsCanUse = new Array<Integer>();
		arrGunsCanUse.add(1);

	}

	public static void putBoolean(int key, boolean val) {
		preferences.putBoolean(String.valueOf(key), val);
		preferences.flush();
	}

	public static boolean getBoolean(int key) {
		return preferences.getBoolean(String.valueOf(key));
	}

	public static void putBoolean(String key, boolean val) {
		preferences.putBoolean(key, val);
		preferences.flush();
	}

	public static boolean getBoolean(String key) {
		return preferences.getBoolean(key);
	}

	public static void putString(String key, String val) {
		preferences.putString(key, val);
		preferences.flush();
	}

	public static String getString(String key) {
		return preferences.getString(key);
	}

	public static void putInterger(String key, int val) {
		preferences.putInteger(key, val);
		preferences.flush();
	}

	public static int getInterger(String key) {
		return preferences.getInteger(key);
	}

	public static void putInterger(int key, int val) {
		preferences.putInteger(String.valueOf(key), val);
		preferences.flush();
	}

	public static int getInterger(int key) {
		return preferences.getInteger(String.valueOf(key));
	}

	public static void putFloat(String key, float val) {
		preferences.putFloat(key, val);
		preferences.flush();
	}

	public static float getFloat(String key) {
		return preferences.getFloat(key);
	}

	public static void setCoin(int coin) {
		Setting.putInterger(COIN, coin);
	}

	public static int getCoin() {
		return Setting.getInterger(COIN);
	}

	public static void setGun(int gun) {
		Setting.putBoolean(GUN + gun, true);
	}

	public static boolean getGun(int gun) {
		return Setting.getBoolean(GUN + gun);
	}

	public static int getGun1(int gun) {
		return Setting.getInterger(GUN + gun);
	}

	public static void setLocot(int locot) {
		Setting.putBoolean(LOCOT + locot, true);
	}

	public static boolean getLocot(int locot) {
		return Setting.getBoolean(LOCOT + locot);
	}

	public static boolean isSound(String name) {
		return Setting.getBoolean(name);
	}

	public static void setSound(String name, boolean val) {
		Setting.putBoolean(name, val);
	}
}
